import request from '@/utils/request'
// import qs from 'qs'

// 动态路由

// OSPF获取状态
export function getOspfStatus (params) {
  var data = fromData(params)
  return request({
    url: 'dynamic_route/getOspfStatus',
    method: 'post',
    data
  })
}

// OSPF设置状态
export function setOspfStatus (params) {
  var data = fromData(params)
  return request({
    url: 'dynamic_route/setOspfStatus',
    method: 'post',
    data
  })
}

// OSPF获取开启的网段
export function getOspfNet (params) {
  var data = fromData(params)
  return request({
    url: 'dynamic_route/getOspfNet',
    method: 'post',
    data
  })
}

// OSPF增加开启的网段
export function addOspfNet (params) {
  var data = fromData(params)
  return request({
    url: 'dynamic_route/addOspfNet',
    method: 'post',
    data
  })
}

// OSPF删除开启的网段
export function delOspfNet (params) {
  var data = fromData(params)
  return request({
    url: 'dynamic_route/delOspfNet',
    method: 'post',
    data
  })
}

// OSPF获取兼容RFC1583状态
export function getOspfRFC (params) {
  var data = fromData(params)
  return request({
    url: 'dynamic_route/getOspfRFC',
    method: 'post',
    data
  })
}

// OSPF设置兼容RFC1583状态
export function setOspfRFC (params) {
  var data = fromData(params)
  return request({
    url: 'dynamic_route/setOspfRFC',
    method: 'post',
    data
  })
}

// OSPF获取路由
export function getOspfRoute (params) {
  var data = fromData(params)
  return request({
    url: 'dynamic_route/getOspfRoute',
    method: 'post',
    data
  })
}

// OSPF获取接口配置信息
export function getOspfIfconfig (params) {
  var data = fromData(params)
  return request({
    url: 'dynamic_route/getOspfIfconfig',
    method: 'post',
    data
  })
}

// OSPF编辑接口配置信息
export function setOspfIfconfig (params) {
  var data = fromData(params)
  return request({
    url: 'dynamic_route/setOspfIfconfig',
    method: 'post',
    data
  })
}

// OSPF添加接口配置信息
export function addOspfIfconfig (params) {
  var data = fromData(params)
  return request({
    url: 'dynamic_route/addOspfIfconfig',
    method: 'post',
    data
  })
}

// OSPF删除接口配置信息
export function delOspfIfconfig (params) {
  var data = fromData(params)
  return request({
    url: 'dynamic_route/delOspfIfconfig',
    method: 'post',
    data
  })
}

// OSPF获取参考宽带
export function getOspfBandwidth (params) {
  var data = fromData(params)
  return request({
    url: 'dynamic_route/getOspfBandwidth',
    method: 'post',
    data
  })
}

// OSPF设置参考宽带
export function setOspfBandwidth (params) {
  var data = fromData(params)
  return request({
    url: 'dynamic_route/setOspfBandwidth',
    method: 'post',
    data
  })
}

function fromData (params) {
  let formData = new FormData()
  for (const it in params) {
    if (!Object.is(params[it], null) && !Object.is(params[it], '')) {
      formData.append(it, params[it])
    }
  }
  return formData
}

// function fromData (params) {
//   var data = qs.stringify(params)
//   return data
// }
